import os
import matplotlib.pyplot as plt

epochs = range(1, 21)
train_loss = [0.3734, 0.3264, 0.3039, 0.2826, 0.2582, 0.2285, 0.1993, 0.1638, 0.1333, 0.1074, 0.0841, 0.0677, 0.0553,
              0.0471, 0.0436, 0.0398, 0.0316, 0.0263, 0.0308, 0.0259]
train_acc = [82.94, 85.515, 86.435, 87.72, 88.69, 90.205, 91.675, 93.415, 94.76, 96.0, 96.88, 97.615, 98.105, 98.43,
             98.52, 98.71, 98.895, 99.175, 98.92, 99.15]
valid_loss = [0.3344, 0.329, 0.3312, 0.3275, 0.328, 0.3493, 0.3591, 0.3827, 0.4188, 0.4608, 0.4966, 0.5534, 0.5968,
              0.5944, 0.6498, 0.703, 0.736, 0.7761, 0.7988, 0.7766]
valid_acc = [84.68, 85.38, 85.56, 85.54, 85.68, 85.28, 85.72, 85.44, 85.54, 84.98, 84.72, 84.64, 84.36, 84.76, 85.3,
             85.22, 85.12, 85.08, 84.36, 85.86]

plt.figure(figsize=(10, 5))
plt.subplot(1, 2, 1)  # 绘制损失曲线
plt.plot(epochs, train_loss, 'bo-', label='Training Loss')
plt.plot(epochs, valid_loss, 'ro-', label='Validation Loss')
plt.title('Training and Validation Loss')
plt.xlabel('Epochs')
plt.ylabel('Loss')
plt.xticks(range(2, 21, 2))
plt.legend()

plt.subplot(1, 2, 2)  # 绘制准确率曲线
plt.plot(epochs, train_acc, 'bo-', label='Training Accuracy')
plt.plot(epochs, valid_acc, 'ro-', label='Validation Accuracy')
plt.title('Training and Validation Accuracy')
plt.xlabel('Epochs')
plt.ylabel('Accuracy')
plt.xticks(range(2, 21, 2))
plt.legend()

plt.tight_layout()
plt.show()
